/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.aseclipse.core.runtime.registry.classes {

import org.aseclipse.core.runtime.registry.IExtension;
import org.aseclipse.core.runtime.registry.IExtensionDelta;
import org.aseclipse.core.runtime.registry.IExtensionPoint;

public class ExtensionDelta implements IExtensionDelta {
    /**
	 * Delta kind constant indicating that the extension has been added to the extension registry.
	 * @see IExtensionDelta#getKind
	 */
	public static const ADDED:int = 1;
	/**
	 * Delta kind constant indicating that the extension has been removed from the extension registry.
	 * @see IExtensionDelta#getKind
	 */
	public static const REMOVED:int = 2;
	private var kind_:int;
	private var extension_:IExtension;
	private var extensionPoint_:IExtensionPoint;

    public function ExtensionDelta(extenpoint:IExtensionPoint, extension:IExtension, kind:int) {
        this.extensionPoint_ = extenpoint;
        this.extension_ = extension;
        this.kind_ = kind;
    }
    
	public function get extensionPoint():IExtensionPoint {
		return extensionPoint_;
	}

	public function set extensionPoint(extensionPointObj:IExtensionPoint):void {
		this.extensionPoint_ = extensionPointObj;
	}

	public function get kind():int {
		return kind_;
	}
	public function get extension():IExtension {
		return extension_;
	}
	public function set extension(exten:IExtension):void {
		this.extension_ = exten;
	}
	public function set kind(kind:int):void  {
		this.kind_ = kind;
	}
	
	public function toString():String {
		return "\n\t\t" + this.extension.getExtensionPointIdentifier() + " - " + this.extension.getUniqueIdentifier() + " (" + getKindString(this.kind) + ")"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
	}
	
	public static function getKindString(kind:int):String {
		switch (kind) {
			case ADDED :
				return "ADDED"; //$NON-NLS-1$
			case REMOVED :
				return "REMOVED"; //$NON-NLS-1$
		}
		return "UNKNOWN"; //$NON-NLS-1$
	}
}
}